package com.desire.test;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author desire
 */
public class _18_objectInOutStream {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("user.dat", true));
        oos.writeObject("aa");
        List<user> us = new ArrayList<user>();
        oos.writeObject(us);

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("user.dat"));
        user user = (com.desire.test.user) ois.readObject();
        System.out.println(user);

    }
}

@AllArgsConstructor
@NoArgsConstructor
@Data
class User implements Serializable {
    private int id;
    private String name;
    private int age;
}
